//index.js
//获取应用实例
var app = getApp()
Page({
	data: {
		screenHeight:app.screenHeight,
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		account:app.setting.account,
		page:1,
		page_id:'',
		pagedata: {},
		region: ['广东省', '广州市', '海珠区'],
		chooseimage:[],
		detail:[],
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (options){
		var the=this;
		var id = parseInt(options.id);
		the.detail(id);
	},
	detail: function(id){
		var the = this;
		app.util.request({
		  'data': {
			'plugin': 'core',
			'action': 'member.cpassword',
			'op': 'get'
		  },
		  success(res) {
			   the.setData({
					member: res.item,
			  })
		  }
		});
	},
	//提交订单
    formSubmit:function(e){
        var that = this;
        var value = JSON.stringify(e.detail.value);
		console.log(value);
        app.util.post({
			'paoq':'core/member.cpassword/post',
			'data':{'realname':value.realname,'pw1':value.pw1,'pw2':value.pw2},
		  success(res){
			   //console.log(res);
			if (res.type != 'error') {
				wx.showToast({
							title: '提交成功',
							icon: 'success',
							duration: 500,
							mask: true,
							success : function() {
								wx.redirectTo({
									'url': '/pages/member/index'
								});
							}
				})
				
			}else{
				app.util.message(res.message,'error');
			}
		  },
		  error: function (err) {
                //console.log(err);
          }
		});
    }
});